package config

import (
	"gopkg.in/yaml.v3"
	"io/ioutil"
	"log"
	"path/filepath"
)

type Config struct {
	TcpServer string `yaml:"tcp_server"`
}

var config Config

func OpenConfigFile() {
	configFile, _ := filepath.Abs("config/config.yml")
	yamlFile, err := ioutil.ReadFile(configFile)
	err = yaml.Unmarshal(yamlFile, &config)
	if err != nil {
		log.Printf("Error %s when opening config file: ", err)
	}
}

func GetTCPServer() string {
	log.Printf("config.TcpServer : %s ", config.TcpServer)
	return config.TcpServer
}
